<h1>Listing driving lessons</h1>

<table>
  <tr>
    <th>Date</th>
    <th>Start time</th>
    <th>End time</th>
    <th>Topic</th>
    <th>Grade</th>
    <% if @current_user.student? %>
      <th>Instructor</th>
    <% else %>
      <th>Student</th>
    <% end %>
    <th></th>
    <th></th>
    <th></th>
  </tr>

<% @driving_lessons.each do |driving_lesson| %>
  <tr>
		<td><%= driving_lesson.date %></td>
    <td><%= driving_lesson.start_time %></td>
    <td><%= driving_lesson.end_time %></td>
    <td><%= link_to driving_lesson.topic.name, driving_lesson.topic %></td>
    <td><%= driving_lesson.grade %></td>
    <% if @current_user.student? %>
      <td><%= link_to driving_lesson.instructor.full_name, driving_lesson.instructor %></td>
    <% else %>
      <td><%= link_to driving_lesson.student.full_name, driving_lesson.student %></td>
    <% end %>
    <td><%= link_to 'Show', timeslot_driving_lesson_path(driving_lesson.timeslot) %></td>
    <% unless @current_user.student? %>
      <td><%= link_to 'Edit', edit_timeslot_driving_lesson_path(driving_lesson.timeslot) %></td>
      <td><%= link_to 'Destroy', timeslot_driving_lesson_path(driving_lesson.timeslot), confirm: 'Are you sure?', method: :delete %></td>
    <% end %>
  </tr>
<% end %>
</table>

<br />
